'; window.popUpWin.document.write(zhtm); window.popUpWin.document.close(); // Johnny Jackson 4/28/98 } //--> Inside AutoCAD 14 -- Ch 17 -- Drawing Hatch Patterns


Inside AutoCAD 14

Previous chapterNext chapterContents


- 17 -

Drawing Hatch Patterns


by Francis Soen

When you need to fill an area with a repetitive pattern, you can use the BHATCH command to create an associative hatch object. In this chapter, you learn how to:

Creating Hatch Patterns Using BHATCH

You draw hatch objects whenever you want to highlight an area on your drawing or if you want to convey information pictorially about a specific area on the drawing. For example, you might have a map with different patterns where each pattern represents a distinct type of terrain.

The BHATCH command is used to draw hatch patterns, which are used when you need to fill an area with a repetitive pattern. This section introduces the BHATCH command and also discusses specifying the pattern, defining hatch boundaries, setting attributes, dealing with islands, and using advanced settings.

To issue BHATCH, choose Hatch from the Draw toolbar. The Boundary Hatch dialog box is displayed (see fig. 17.1).

Figure 17.1 Boundary Hatch dialog box of BHATCH.

To draw a hatch object, you need to specify the pattern and its parameters, and define the limits of the area to be hatched. These subjects are covered in detail in the following sections.

Specifying the Pattern

The first decision you are faced with is choosing what pattern type to use. You have the option of using one of many predefined patterns, which is the first topic discussed. You can also choose a user-defined pattern, a custom pattern, or imitate an existing hatch object and its parameters. These options are discussed in the sections that follow.

Predefined Patterns

The default pattern type is that of a predefined pattern. AutoCAD comes with a number of predefined patterns. Figure 17.2 shows a sampling of the patterns included with AutoCAD.

Figure 17.2 Some sample hatch patterns supplied with AutoCAD.

To select one of the predetermined patterns as your hatch pattern, choose the pattern you want from the Hatch Pattern Palette dialog box, which you display by choosing the Pattern button. When you choose a pattern, a sample of the pattern is displayed in the Pattern Type section of the Boundary Hatch dialog box. You can move on to the next available pattern by picking the sample pattern display. Another option is to select the pattern name from the Pattern drop-down list.

Choosing Scale and Angle Settings

After you choose a pattern, you need to set the Scale and Angle settings. The Scale setting is a scaling factor used to scale the pattern's size up and down, much as LTSCALE is used to control the generation of linetypes. The Angle setting enables you to rotate the pattern.

Some of the patterns are designed to represent real building materials and are defined with the appropriate dimensions. The pattern AR-B88, for example, is used to represent 8" * 8" blocks; using a scale factor of 1, the blocks are drawn as 8" * 8" blocks. Other patterns, such as ANSI31, are simply a symbol or linetype drawn in a repetitive fashion. For patterns representing real building materials, a scale of 1 (or thereabouts) should be used for full-size drawings, whereas the scale used for the symbolic patterns should be related to the plot scale for which the drawing is set up. As a general rule, patterns that represent real building materials have an asterisk in the upper-left corner of the sample display.


[BEEG]TIP: If you set the scale to too small a value, the pattern can take a while to be generated. If you set the scale to too large a value, the pattern can get so big that you cannot even see a portion of it within the area being filled. Use the Preview Hatch button as you fine-tune the parameters.

Metric (ISO) Patterns

Some patterns are designed for use in metric drawings; their names begin with ISO and are near the bottom of the list of predefined patterns. As with the metric linetypes, metric hatch patterns should be used only in metric drawings because the patterns are defined in millimeters and would appear too large in drawings set up in English units. If you do choose to use a metric pattern, the ISO Pen Width setting is enabled. Choosing a pen width sets the initial value for the scale setting equal to the chosen pen width, but you are free to set the scale setting yourself.

Linetype and Color Settings

The hatch object is drawn with the current linetype and color settings. If you want to generate the hatch pattern as displayed in the sample box, make sure that the current linetype is continuous or that you are drawing on a layer with a continuous linetype, using a BYLAYER current linetype setting.

User-Defined Patterns

Another type of pattern, a user-defined pattern, is a simple pattern that consists of one or two sets of parallel lines (see fig. 17.3).

The angle and spacing of the first set of parallel lines is set with the Angle and Spacing settings. A second set of parallel lines can be generated perpendicular to the first set by enabling the Double setting, which you can find in the lower-left corner of the Boundary Hatch dialog box. The spacing for the second set of lines is the same as for the first set (see fig. 17.3).


TIP: You can draw a variety of patterns by varying the current linetype with which the pattern is drawn.

Figure 17.3 Two examples of user-defined patterns.

Custom Patterns

Additional hatch patterns, similar to the patterns provided with AutoCAD, can also be defined. The additional pattern definitions are either added to the ACAD.PAT file (or ACADISO.PAT), or each definition is stored in its own individual file (named with a .PAT file name extension). The Individual hatch pattern files are referred to as "Custom Pattern" files. To access one of these custom pattern files, choose the Custom Pattern type, and then specify the file name in the Custom Pattern text edit box.

Specifics on how to create your own hatch patterns are discussed in the section "Creating Custom Hatch Patterns," toward the end of this chapter.

Inherit Properties

If you want to duplicate an existing hatch object in the drawing and the settings used to generate it, choose the Inherit Properties button (located in the lower-right quadrant of the Boundary Hatch dialog box) and select the hatch to be duplicated. The settings for the selected pattern are then retrieved and displayed in the Boundary Hatch dialog box.

Defining the Hatch Boundaries

After a pattern and its settings have been selected, the boundaries of the area to be filled must be defined. The area to be filled has to be completely enclosed by one or more objects (see fig. 17.4). You can define the boundaries either by choosing pick points or by selecting the objects. Both methods are discussed in the following sections.

Figure 17.4 Defining simple areas for hatching with one or more objects.

In figure 17.4, Area A is defined with a circle (a closed object). Area B is defined with a series of lines that meet end-to-end. Area C is defined with several lines and an arc that cross over each other and do not meet end-to-end. The objects that define the area to be filled are referred to as boundary objects.

Using Pick Points

When you choose the Pick Points button in the Boundary Hatch dialog box, the overall hatch area can be delineated automatically by BHATCH. All you have to do is pick a point inside the area that is to be filled; this point is referred to as an internal point. With this method, if multiple boundary objects are used to define the hatch area, the boundary objects do not have to meet end-to-end (refer to Area C in fig. 17.4).

Selecting Objects

A less often used option for delineating the area to be hatched is to choose the Select Objects button in the Boundary Hatch dialog box. With this method, you must select the objects that define the area to be hatched. If more than one boundary object exists, the objects must meet end-to-end, as illustrated by Area B in figure 17.4. This method produces erroneous hatch objects with Area C of figure 17.4 because the boundary objects in that area do not meet end-to-end.

Setting the Attributes

By default, the BHATCH command generates an associative hatch object. Associative means that the boundary objects are linked to the hatch object such that when the boundary objects are modified, the hatch object is also modified to conform to the modified boundaries. Furthermore, an associative hatch object's pattern, and the settings used to generate the pattern, can easily be modified with the HATCHEDIT command.

You can choose to disable the Associative setting, but doing so deprives you of the aforementioned advantages when you need to edit the hatch object. Furthermore, you can choose to generate the hatch object as an exploded hatch. By definition, an exploded hatch is not an associative object and is not a single object, but rather a collection of lines.


WARNING: Unless you have a very good reason not to, always use the default setting of generating an associative hatch object. Otherwise, the hatch object will not be modified to conform when you modify the boundary objects.

Sometimes the area you want to hatch is an area with subareas within it. These more complicated scenarios are discussed in the next section.

Dealing with Islands

Enclosed areas within the overall area to be hatched are referred to as islands. You can even have islands within islands (see fig. 17.5). Text and mtext objects lying within the area to be hatched are also considered islands.

Figure 17.5 Defining complex areas with islands.

The pick points method for defining the hatch area automatically detects the islands. If you use the select objects method, you have to explicitly select the boundary objects defining the islands for BHATCH to recognize their presence. The islands themselves are defined with one or more objects, just as you would draw the overall hatch area.

The way islands are treated by BHATCH is controlled by the hatch style setting, which is set by choosing the Advanced button in the BHATCH dialog box and then choosing from the Style drop-down list (see fig. 17.6). The three available styles are Normal, Outer, and Ignore. Figure 17.7 shows how the same islands are treated when using the different styles.

Figure 17.6 The Advanced Options dialog box of BHATCH.

Figure 17.7 Islands using the Normal, Outer, and Ignore hatch styles.

The default style, Normal, is applicable in most situations. It creates alternating bands of hatching. The Ignore style creates a hatch object that is drawn through the islands. With the Outer style, only the outermost area is hatched. The Outer style is useful when you are hatching overlapping areas with different patterns. Figure 17.8 shows such a situation.

Figure 17.8 Using the Outer style to hatch overlapping areas.

One way to approach the problem of hatching overlapping areas is to pick point 1 and, using the Outer style, hatch the outermost area first. Then pick point 2 and the Outer style, and hatch the next area in, and so on.

BHATCH can also be used on regions. Islands in a region are recognized by BHATCH and are treated according to the current hatch style setting.

In addition to the hatch style settings already discussed, other advanced settings are available to work with in BHATCH.

Choosing Advanced Settings

Choosing the Advanced button displays the Advanced Options dialog box. More often than not, you will not need to change any of these settings.

Define Boundary Set

Normally, the pick points method for delineating the area to be hatched examines all the objects on the screen. You can, however, choose the Define Boundary Set button and explicitly select the objects to be examined for valid hatch boundaries. This option is useful when you have a crowded drawing and want to speed up the algorithm used with the pick points method by restricting the number of objects that are examined.

Style Setting

The Style setting determines how islands are treated. It is discussed earlier, in the "Dealing with Islands" section.

Island Detection Setting

Disabling the Island Detection setting forces the algorithm used with the pick points method to forgo detecting islands. This setting should be left on.

Retain Boundaries Setting

When the hatch area boundary and islands are defined, the areas are automatically delineated with temporary polylines, which normally are removed after the hatch pattern is generated. If you enable the Retain Boundaries setting, the temporary polylines are not removed and are drawn on the current layer. You can even choose to retain the polylines as a region. Enabling the Retain Boundaries option is most useful when the area is delineated by multiple objects and you want a single polyline or region to represent the hatch area. If you subsequently use the AREA command on the resulting polyline(s), or MASSPROP on the resulting region, you can easily determine the area.

The following exercise takes you through the necessary steps of using BHATCH to fill some areas on several details with a pattern.

FILLING IN AREAS WITH BHATCH

1. Open the drawing SOLID.DWG. This drawing contains a 3D solid model. The view you initially see is of paper space with several viewports defined. The viewports themselves are on layer VPORTS, which is frozen.

2. Restore the view ENDVIEW. Make sure that you are in floating model space (double-click on the Paper button, if necessary). Make the Right End view the current viewport by clicking anywhere in that detail. Make a new layer, HATCH, and make sure that it is the current layer.

3. Choose Hatch from the Draw pull-down menu, choose the pattern ANSI34, and set the scale to 1 and the rotation angle to 0. Choose the Pick Points button and pick 1 (see fig. 17.9). Click on the Apply button. The results should look like figure 17.9.

Figure 17.9 Hatching the details.

4. Make sure you are in paper space and restore the view SECTION, make floating model space current, and repeat the BHATCH command using the same pattern and parameters as before. Click on the Pick Points button and pick 2 and 3 (refer to fig. 17.9). Click on the Apply button. The results should look like figure 17.10.

5. Save the drawing; you are finished with this exercise.

Figure 17.10 SOLID.DWG with the hatch objects drawn.

Editing Hatch Objects

To edit hatch objects, issue the HATCHEDIT command by choosing Hatch from the Object submenu of the Modify pull-down menu. The resulting Hatchedit dialog box is similar to the Boundary Hatch dialog box, but with several settings disabled (see fig. 17.11).

Figure 17.11 The Hatchedit dialog box.

With HATCHEDIT, you can change the pattern of the hatch object or the parameters that control the generation of the pattern. You also can access the Hatchedit dialog box by choosing the Hatch Edit button in the Modify Hatch dialog box (DDMODIFY command).

Editing the Hatch Boundaries

If you stretch or move the boundary objects defining the overall area of an associative hatch object, the hatch object automatically adjusts to fit the modified boundaries. If you move, delete, or stretch any of the islands, the hatch object also is adjusted.

If you delete any of the boundary objects defining the overall hatch area or islands (resulting in an open rather than closed area), the associativity is removed from the hatch object and the hatch loses its capability to adjust to changing boundaries.


WARNING: Islands should never be moved beyond the outermost hatch boundary. If you ignore this advice and do so anyway, you may encounter problems later, such as the hatch adjusting incorrectly, move as you continue to edit the hatch or the boundary objects.

Exploding Hatch Objects

You can explode a hatch object into its constituent lines with the EXPLODE command. Exploding a hatch object removes the associativity of the object. Additionally, the single hatch object is replaced by the group of line objects that make up the pattern. Exploding a hatch object does enable you to edit the individual lines of the hatch, but in most cases you lose more than you gain.

Using Object Snap

A hatch object is composed of lines. Therefore, you can use the same object snap modes (such as endpoint or midpoint) on the lines in an associative hatch object as you use on lines.


NOTE: In earlier versions of AutoCAD, a hatch was actually a form of a block, and you could use the insert object snap mode on a hatch. In R14, a hatch is an object in itself and has no insertion point.

The following exercise shows how to modify the hatch objects that you drew in the previous exercise.

STRETCHING THE BOUNDARIES OF THE HATCH OBJECT

1. Continue to use the drawing SOLID.DWG found in the Chapter 17 folder on the accompanying CD-ROM. Restore the view ENDVIEW. Make sure that you are in floating model space and that the current viewport is that of the End View.

2. Choose Hatch from the Objects submenu of the Modify pull-down menu, select the hatch object, change the pattern to ANSI35, and click on the Apply button.

3. Restore the view SECTION. Make sure that the current viewport is that of the Section view. Choose Stretch from the Modify toolbar, and choose 1 and 2 (see fig. 17.12).

4. Type in the displacement -0.5,0 for the first stretch point, and press the Enter key for the second stretch point.

5. You are finished with this drawing; save and exit the drawing.

Figure 17.12 Stretching the boundaries.

Dealing with Layers and Visibility

There are two methods with which you can control the visibility of hatch objects, layers or the system variable FILLMODE. Both are discussed in the following sections.

Controlling Visibility with Layers

Quite often, the hatch object is drawn on a layer separate from the layer(s) containing the boundary objects. Drawing the hatch object on a separate layer enables you to make the hatch object invisible, while leaving the boundary objects visable, by freezing or turning off the hatch layer. When the time comes to update the hatch object, however, certain consequences must be dealt with because the hatch boundaries have been modified. When you lock the hatch layer and change the boundary objects some consequences will result. The following sections discuss these consequences.

If the hatch layer is frozen and the boundary objects are modified, then the associativity of the hatch object is removed and the hatch object cannot adjust to the changed boundaries.

If the hatch layer is turned off and the boundary objects are modified, the hatch object still adjusts to the changed boundaries. The adjustment is evident when the hatch layer is turned back on.

If the hatch layer is locked and the boundary objects are modified, the hatch object is not adjusted to the changed boundaries; however, the hatch object's associativity remains intact.

To force the hatch object to adjust to the modified boundary objects, first unlock the hatch layer. Then select the hatch object with the HATCHEDIT command and click on the Apply button without making any changes to the settings. If at any time the hatch object fails to adjust correctly to the modified boundaries, you can force AutoCAD to try again by selecting the hatch object with the HATCHEDIT command and clicking on the Apply button without changing any of the parameters.


TIP: To avoid accidentally removing the associativity from hatch objects, get into the habit of turning off the hatch layer rather than freezing it.

Controlling Visibility with FILLMODE

You can control the visibility of all hatch objects in a drawing by setting the FILLMODE system variable. When FILLMODE is turned off (set to 0), all hatch objects become invisible, regardless of the status of the layers on which the hatch objects reside. Of course, you must issue the REGEN or REGENALL command to affect existing hatch objects. The disadvantage of using FILLMODE is that FILLMODE also affects solids, multilines, and wide polylines.

Completely Filling an Area


NOTE: In earlier versions of AutoCAD, when you wanted to completely fill an area (coloring an area, for example), you either drew solids or generated a hatch with settings that created a dense pattern of hatch lines. In R14, a new pattern has been provided to take care of filling areas: the solidfill pattern. Using the solidfill pattern is much more efficient, in terms of plotting and regenerating the drawing, than the old method of drawing a hatch with settings that result in a dense pattern.

Selecting Hatch Objects

In selecting an associative hatch object, you can choose not only to select the hatch object itself but also to have the boundary objects associated with the hatch object automatically included in the selection. In the Object Selection Settings dialog box (displayed by choosing Selection from the Tools pull-down menu), is a setting labeled Associative Hatch. By default, this option is disabled so that when you select a hatch object, the associated boundary objects are not selected automatically. If you enable the Associative Hatch option, the boundary objects associated with the selected hatch object are automatically included in the selection.

Selecting a hatch object's boundary objects without selecting the hatch object itself can be difficult to do without magnifying the view, turning off the hatch object's layer, or turning FILLMODE off and regenerating the drawing. Another tool is available, however, that you can use to select the boundary objects that can be more efficient at time--object cycling.

Using the Direct Hatch Option of HATCH

The older version of the BHATCH command is HATCH. Because it is the older version, it is not located on any of the pull-down menus or toolbars, and must be typed. The major drawback to using HATCH is that it can draw only nonassociative hatch objects.

Despite this, HATCH does have an option that you may find useful: the Direct Hatch option. The Direct Hatch option enables you to define on-the-fly the area to be hatched, removing the necessity to draw the boundary objects before drawing a hatch object. The direct option is most useful when you have a large area to hatch and want to hatch representative patches, not the entire area.

After you issue the HATCH command, choose a pattern, and set the associated settings, you are prompted to select the boundary objects. To invoke the Direct Hatch option, do not select any objects. Press Enter. Then you define the hatch boundary by using options similar to those in the PLINE command. In effect, you are drawing the hatch boundary with a temporary polyline. After you finish defining the area with a closed polyline, the nonassociative hatch object is drawn. If you want, you can even choose to retain the polyline.

In the next section, you learn how to create your own hatch patterns.

Creating Custom Hatch Patterns

It is possible to add new patterns to the ones supplied with AutoCAD. You can add the new patterns (custom hatch patterns) to the file ACAD.PAT (or ACADISO.PAT) or define each new pattern in its own file. ACAD.PAT and ACADISO.PAT are both found in the \ACADR14\SUPPORT directory (also referred to as custom pattern files). If you choose to define each pattern in its own file, the file must have the same name as the pattern and have a file name extension of .PAT. The new custom patterns files should be placed in one of the directories defined in the support file search path (see the PREFERENCES command). Because hatch pattern files are ASCII files, a text editor is all you need to add to ACAD.PAT or to create your own file.

A hatch pattern consists of one or more families of parallel pattern lines. The rules for defining a pattern line are the same as those for defining a new linetype, except that no text or shapes can be included in the definition of the pattern line.


TIP: Although the rules for defining a hatch pattern are relatively straightforward, implementing the rules takes time, effort, and patience. A much easier and more cost-efficient solution is to buy the pattern you need from one of several third-party developers (check with your AutoCAD dealer). If you definitely want to define your own pattern, read on.

Defining the Header Line

The first line in any pattern definition is the header line:

*pattern-name [, description]

The name cannot contain any blanks. The description is optional (as is the preceding comma), and is only used by the ? option of the HATCH command.


NOTE: If you choose to place the pattern name in its own custom pattern file, you must use the same name for both the file and the pattern.

Defining the Pattern Lines

The header line is followed by one or more pattern line descriptors, one for each family of lines to be drawn, with the following syntax:

angle, x-origin, y-origin, delta-x, delta-y [,dash-1, dash-2, ...]

The following line descriptor, for example, would result in the hatch shown on the left in figure 17.13:

*L45, 45 degree lines @ 0.25 units apart
45,0,0,0,0.25

Figure 17.13 Samples of the L45 and TRIANG patterns.

Each family of lines starts with one line, and the line's angle and origin are specified by the first three numbers of the line descriptor. In the preceding example, the first line is drawn at a 45-degree angle through the point 0,0. The family of lines is generated by offsetting each successive line by delta-x and delta-y offsets, with delta-x measured along the line and delta-y measured perpendicular to the lines. In the example, each succeeding line is offset 0 in the x direction and 0.25 in the y direction. With no other dash specifications specified, AutoCAD draws the lines with the current linetype.

The next example is a pattern taken from the file ACAD.PAT, and is shown on the right in figure 17.13:

*TRIANG, Equilateral triangles
60, 0,0, .1875,.324759526, .1875,-.1875
120, 0,0, .1875,.324759526, .1875,-.1875
0, -.09375,.162379763, .1875,.324759526, .1875,-.1875

In this example, the pattern consists of three families of lines: one family at 60 degrees, another at 120 degrees, and the third at 0 degrees. The dash specifications (the last two numbers in each line) indicate that each line is to consist of a 0.1875 dash and a 0.1875 space repetitive pattern.

You can have as many pattern line descriptors as you want, but each line can be no more than 80 characters long.

Adding Sample Slides

The samples of the patterns displayed in the Boundary Hatch dialog box are slides that are stored in the slide library file ACAD.SLB. If you want a sample of a custom pattern you have added to the file ACAD.PAT to be displayed in the dialog box, you must draw a sample of the pattern, make a slide of the drawing, and add the slide to the ACAD.SLB file (also found in the \ACADR14\SUPPORT directory). The slide file must have the same name as the pattern it represents. See Chapter 23, "Creating Scripts and Slide Libraries," for the commands and procedures used to create slides.

You can use the program SLIDELIB, which is supplied with AutoCAD, to recreate the slide library file ACAD.SLB with your additional new slides. Unfortunately, SLIDELIB cannot be used to add new slides to a library file. In effect, you must recreate the entire library file when you add to it. To recreate ACAD.SLB, you need the original slide files that were used to create ACAD.SLB (and these slide files are not supplied with AutoCAD).

Several third-party packages are available, however, that make managing, deleting from, and adding to a slide library file easier to do.


NOTE: One such package, a DOS program called MAKSLB21, is provided on the accompanying CD in the Chapter 17 folder. Contact your AutoCAD dealer to see what other packages are available.

Using BOUNDARY to Delineate Areas and Islands

The BOUNDARY command is a variation of the BHATCH command.

BOUNDARY is used to create polylines delineating an overall area and the islands within that area. If you want, you can create a region rather than polylines. The boundary delineation algorithm employed by BOUNDARY is the same as the algorithm employed by BHATCH. The Boundary Creation dialog box is a variation of the Advanced Options dialog box of the BHATCH command (see fig. 17.14). Use Boundary when all you want to do is to delineate an area and its islands but not hatch the area.

Figure 17.14 Boundary Creation dialog box of BOUNDARY.

As with the BHATCH command, the overall area and islands must be enclosed by one or more objects.

Summary

Hatching is a powerful tool for clarifying the meaning of your drawing or for conveying information to the reader. It is easy to apply, using BHATCH, and just as easy to edit with HATCHEDIT. Drawing hatch objects on a separate layer is always a good idea. Although you can create your own hatch patterns, buying the pattern you need is usually more cost-effective. In the next chapter, "Productive Dimensioning," you learn about another group of associative objects, the group of dimension objects.


Previous chapterNext chapterContents

© Copyright, Macmillan Computer Publishing. All rights reserved.